
// ---------------------------------------- 登录 ----------------------------------------
$('form').on('submit', function (e) {
  e.preventDefault()
  let data = $(this).serialize()

  $.ajax({
    type: "POST",
    url: "/api/login",
    data: data,
    success: function (res) {
      if (res.status === 0) {
        localStorage.setItem('token', res.token)
        layer.msg('登陆成功', () => {
          location.href = './index.html'
        })
      } else {
        layer.msg('账号或密码错误')
      }
    }
  });
})